package com.webservice;

import com.carpark.ejb.Model.AccountingdataModel;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import javax.inject.Named;

/**
 *
 * @author Krzysztof
 */
@Named("payer")
public enum Payer {

    PRIVATE_PERSON("PrivatePerson","Osoba prywatna"),
    COMPANY("Company","Firma");
    private String name;
    private String label;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getLabel() {
        return label;
    }

    Payer(String name,String label) {
        this.name = name;
        this.label=label;
    }

    public String getPayerTypeName() {
        return this.name;
    }
    
    public List<String> getAllTypes() {
        ArrayList<String> results = new ArrayList<String>();
        results.add(PRIVATE_PERSON.getPayerTypeName());
        results.add(COMPANY.getPayerTypeName());
        return results;
    }
    
   
        public String fromValueToLabel(AccountingdataModel ad) {
            
        String result = "brak";
        for (Payer ct : getAll()) {
            if (ct.name.equals(ad.getPayerType())) {
                result = ct.getLabel();
            }
        }
         return result;
    }
          public String fromValueToLabel(String s) {
            
        String result = "brak";
        for (Payer ct : getAll()) {
            if (ct.getPayerTypeName().equals(s)) {
                result = ct.getLabel();
            }
        }
         return result;
    }
      
          public List<Payer> getAll() {
        return new ArrayList<Payer>(Arrays.asList(Payer.values()));
    }

    
}
